feat: add support for serialization compatibility with newer Laravel#389
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
Newer versions of Laravel added the
#[AllowDynamicProperties]attribute toCallQueuedListener. Without it, PHP 8.2+ emits deprecation notices when dynamic properties are assigned during unserialization, and stricter future PHP versions will throw errors outright.More critically, this creates a cross-version serialization breakage: if a job is serialized (pushed to queue) with a Laravel version where
CallQueuedListenercarries additional properties — then deserialized (popped from queue) by a worker running a different version without the attribute — PHP rejects the unknown properties. The result is a fatal unserialization error that silently kills queued jobs.Changes
src/event/src/CallQueuedListener.php·src/event/illuminate/CallQueuedListener.phpAdded the
#[AllowDynamicProperties]attribute to bothHypervel\Event\CallQueuedListenerand theIlluminate\Events\CallQueuedListenershim. This mirrors the upstream Laravel change and ensures dynamic properties set during unserialization are accepted without error, regardless of which version serialized the payload.src/queue/src/CallQueuedClosure.phpPorted the
name()feature from newer Laravel, which allows queued closures to carry a human-readable display name:public ?string $name = null;propertyname(string $name): staticfluent methoddisplayName()to prefix the output when a name is set:MyJob - Closure (DispatchesJobs.php:42)Why both
CallQueuedListenerfiles?Hypervel ships two variants of
CallQueuedListener:Hypervel\Event\CallQueuedListener— the native Hypervel implementationIlluminate\Events\CallQueuedListener— a shim under the Illuminate namespace for compatibility with packages that dispatch listeners via the standard Laravel namespaceBoth must carry the attribute so payloads are interchangeable regardless of which class path was used to serialize them.
Impact
CallQueuedListenerclass shapes$namedefaults tonullanddisplayName()output is unchanged when no name is set#[AllowDynamicProperties]is available since PHP 8.1)